﻿//
// AdminView.xaml.cs
//
// Authors:
//    Anders Gade Nørskov <09549@iha.dk
//    Lars Rønde Hansen <09548@iha.dk>
//    Claus Jørgensen <10229@iha.dk>
//
using System.Windows;
using System.Windows.Controls;

using GalaSoft.MvvmLight.Messaging;

namespace RSD.View
{
    using ViewModel.Messages;

    /// <summary>
    /// Interaction logic for AdminView.xaml
    /// </summary>
    public partial class AdminView : Page
    {
        private static bool registered = false;

        public AdminView()
        {
            InitializeComponent();

            if (!registered)
            {
                registered = true;

                Messenger.Default.Register<OpenCreateItemClassificationViewMessage>(this,
                    msg =>
                    {
                        var dialog = new CreateItemClassificationView();
                        dialog.Owner = this.FindVisualAncestor<Window>();
                        dialog.ShowDialog();
                    });

                Messenger.Default.Register<OpenCreateUserViewMessage>(this,
                    msg =>
                    {
                        var dialog = new CreateUserView();
                        dialog.Owner = this.FindVisualAncestor<Window>();
                        dialog.ShowDialog();
                    });

                Messenger.Default.Register<OpenCreatePositionViewMessage>(this,
                    msg =>
                    {
                        var dialog = new CreatePositionView();
                        dialog.Owner = this.FindVisualAncestor<Window>();
                        dialog.ShowDialog();
                    });
            }
        }
    }
}
